#! /bin/bash
export LANG=zh_CN.UTF-8
PRESTO_HOME=/export/server/presto/bin/presto
MYSQL_HOME=/usr/bin/mysql


echo '========================================'
echo '================开始导出================='
echo '========================================'


${MYSQL_HOME} -h192.168.88.80 -p3306 -uroot -p123456 -e "
CREATE DATABASE IF NOT EXISTS yp_olap DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
use yp_olap;
drop table IF EXISTS edu_stu.rpt_area_customer_cnt_day_month_year;
DROP TABLE IF EXISTS edu_stu.rpt_customer_cnt_day_month_year;
DROP TABLE IF EXISTS edu_stu.rpt_depart_customer_cnt_day_month_year;
DROP TABLE IF EXISTS edu_stu.rpt_effective_customer_cnt_day;
DROP TABLE IF EXISTS edu_stu.rpt_effective_ratio_customer_datetime;
DROP TABLE IF EXISTS edu_stu.rpt_origin_channel_customer_cnt_day_month_year;
DROP TABLE IF EXISTS edu_stu.rpt_school_customer_cnt_day_month_year;
drop table if exists edu_stu.rpt_subject_customer_cnt_day_month_year;

"

${PRESTO_HOME} --catalog hive --server 192.168.88.80:8090 --execute "
--客户意向主题
create table mysql.edu_stu.rpt_area_customer_cnt_day_month_year
as
select
    date_time,
    year_code,
    year_month,
    year_month_day,
    time_type,
    group_type,
    if(area is null,'未知',area) as area,
    clue_state,
    origin_type,
    id_count
from hive.edu_rpt.rpt_area_customer_cnt_day_month_year;


create table mysql.edu_stu.rpt_customer_cnt_day_month_year
as
select * from hive.edu_rpt.rpt_customer_cnt_day_month_year;


create table mysql.edu_stu.rpt_depart_customer_cnt_day_month_year
as
select * from hive.edu_rpt.rpt_depart_customer_cnt_day_month_year;


create table mysql.edu_stu.rpt_origin_channel_customer_cnt_day_month_year
as
select * from hive.edu_rpt.rpt_origin_channel_customer_cnt_day_month_year;


create table mysql.edu_stu.rpt_school_customer_cnt_day_month_year
as
select * from hive.edu_rpt.rpt_school_customer_cnt_day_month_year;


create table mysql.edu_stu.rpt_subject_customer_cnt_day_month_year
as
select * from hive.edu_rpt.rpt_subject_customer_cnt_day_month_year;

--客户线索主题

create table mysql.edu_stu.rpt_effective_customer_cnt_day
as
select * from hive.edu_rpt.rpt_effective_customer_cnt_day;


create table mysql.edu_stu.rpt_effective_ratio_customer_datetime
as
select * from hive.edu_rpt.rpt_effective_ratio_customer_datetime;
"

echo '========================================'
echo '=================success================'
echo '========================================'